<?php
//**************************************************************************
//
//            (C) Okulov Rostislav, 2011
//
//**************************************************************************

/*
 ***************************************************************************
 *                                                                         *
 *   This source is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This code is distributed in the hope that it will be useful, but      *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   A copy of the GNU General Public License is available on the World    *
 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 *   obtain it by writing to the Free Software Foundation,                 *
 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 *                                                                         *
 */
 
   session_start();
   include ('mysql_connect.php');
   include ('func_list.php');

   if (preg_match('/^[a-z0-9]{4,11}$/i',$_GET['userid'])) {

      $link = mysql_connect($dbhost, $dbuser, $dbpassword);
      if (empty($link)) {
         echo 'No connection to MySQL'; 
         exit;
      }
      $userinfo = array();

      mysql_select_db($dbname, $link);
      $query="SELECT * FROM users WHERE login='".mysql_escape_string($_GET['userid'])."'";
      $result = mysql_query($query);
      if (mysql_num_rows($result) > 0) {
         $userinfo = mysql_fetch_array($result);
      }
   } else
      echo 'No such words in database ;)';  
?>
<form action="" method="GET">
<span>Никнейм: <?php echo $_GET['userid']; ?></span><br />
<!--span>E-mail: <?php echo $userinfo['email'];?> </span-->
</form>

<span>User registered at: <?php echo $userinfo['regtime']; ?></span><br />
<span>User was here at: <?php echo $userinfo['lastvisit']; ?></span><br />
<?php
   $query="SELECT count(*) FROM comments WHERE userid='".mysql_escape_string($_GET['userid'])."'";
   $result = mysql_query($query);
   if (mysql_num_rows($result) > 0) {
      while ($line = mysql_fetch_row($result)){
         echo '<span>Total comments: </span>'.$line[0];
      }
   } else echo 'Use do not have comments.';
   mysql_close($link);
?>
